home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20021006-20030409 / 000222_fdc@columbia.edu_Sat Jan 18 18:38:18 EST 2003.msg < prev    next >
Text File  |  2020-01-01  |  5KB  |  103 lines

  1. Article: 14013 of comp.protocols.kermit.misc
  2. Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
  3. From: fdc@columbia.edu (Frank da Cruz)
  4. Newsgroups: comp.protocols.kermit.misc
  5. Subject: Case Study #25: Remote Access
  6. Date: 18 Jan 2003 18:37:34 -0500
  7. Organization: Columbia University
  8. Lines: 87
  9. Message-ID: <b0cofu$6ut$1@watsol.cc.columbia.edu>
  10. NNTP-Posting-Host: watsol.cc.columbia.edu
  11. X-Trace: newsmaster.cc.columbia.edu 1042933055 9487 128.59.39.139 (18 Jan 2003 23:37:35 GMT)
  12. X-Complaints-To: postmaster@columbia.edu
  13. NNTP-Posting-Date: 18 Jan 2003 23:37:35 GMT
  14. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:14013
  15.  
  16.  
  17. A question that comes in with increasing frequency is "How do I set Kermit
  18. up for incoming connections and offer the user a simple interface to choose
  19. among the services I want to provide?"
  20.  
  21. There are several aspects to this question. First is how to make Kermit
  22. accept incoming connections. This can be done with the ANSWER command if
  23. users are to dial in with modems, or with SET HOST * on the Internet. You
  24. can even run a Kermit script out of inetd. Of course remote access raises
  25. all sorts of other questions about authentication and security which are
  26. discussed elsewhere.
  27.  
  28. One form of remote access that also takes care of security is the Internet
  29. Kermit Service. This presents the user with either the Kermit program prompt
  30. and command interface or Kermit's server-mode packet interface. And for
  31. completeness, I should also mention Kermit 95's Host Mode.
  32.  
  33. But some people want to set up their own custom interface for incoming users. 
  34. Kermit lets you do this too, on the following types of connections: 
  35.  
  36.  .  Dialed, using the ANSWER command; for example: 
  37.  
  38.       set modem type usrobotics
  39.       set port /dev/ttyS0
  40.       if fail exit 1 Port not available
  41.       set speed 5700
  42.       set flow rts/cts
  43.       answer
  44.       if success take scriptfilename
  45.  
  46.  . Internet, using the SET HOST * command; for example: 
  47.  
  48.       set host * 3000 /raw
  49.       if fail exit 1 Incoming connection failed
  50.       take scriptfilename
  51.  
  52.  . Internet via inetd. In this case you would have Kermit execute your
  53.    script as soon as a connection came in. In Unix, this requires an entry
  54.    in /etc/inetd.conf to set up a service name and parameters, and one in
  55.    /etc/services to associate the service name with a TCP port number. This
  56.    one is a bit tricky and might also require a few of the recent fixes
  57.    found in the C-Kermit daily builds (if anybody is interested in this
  58.    option, speak up).
  59.  
  60. But no matter what way the user comes in, and leaving aside the question of
  61. authentication (for which there are many, many possibilities), we reach the
  62. point where the script needs to interact with the user, and quickly discover
  63. two problems:
  64.  
  65.  . Commands such as ASK and ECHO do not communicate with the user. These
  66.    commands are for use on Kermit's controlling terminal, not on its
  67.    communications connection.
  68.  
  69.  . In some cases (such as under inetd), Kermit doesn't even have a
  70.    controlling terminal.
  71.  
  72. For these reasons, you must use the OUTPUT and INPUT commands to communicate
  73. with the user, and your script must perform all the functions of the
  74. terminal driver, which is not active in this case. This includes echoing of
  75. each character, echoing CR as CRLF, and processing of editing keystrokes
  76. such as Backspace and interrupts such as Ctrl-C. It's not as difficult as it
  77. sounds. To get you started, I've placed a new script in the script library,
  78. called remoteaccess. Here's the URL:
  79.  
  80.   ftp://kermit.columbia.edu/kermit/scripts/ckermit/remoteaccess 
  81.  
  82. This script should work in any relatively recent version of C-Kermit or
  83. Kermit 95. It gives the user just five commands: HELP, ECHO, LIST, SEND, and
  84. EXIT. You should be able to use it as a template in fill in any other
  85. commands you wish.  For simplicity, it offers just a prompt-and-command
  86. interface. A formatted-screen BBS-style interface could be done too (as we
  87. have done, in fact, in Kermit 95 Host Mode). The script includes a "SET
  88. ROOT" command to prevent users from accessing any files outside the tree
  89. rooted (in this case) at its current directory; this is an essential command
  90. for anybody writing remote-access scripts.
  91.  
  92. A few other items in the script are worth mentioning: 
  93.  
  94.  . Command parsing is done by Kermit's \ftablelook() function, which allows
  95.    for abbreviations, synonyms, etc. 
  96.  . Alphabetic case is ignored via a simple setting (SET CASE OFF). 
  97.  . The DOLIST macro shows how to construct and transmit a directory listing. 
  98.  . All sorts of other features are illustrated: compact substring notation,
  99.    array manipulation, extraction of array segments, splitting lines into
  100.    words, etc etc. 
  101.  
  102. - Frank
  103.